﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Text;


namespace John
{
    /// <summary>
    /// Summary description for ShowDialog
    /// </summary>
    public class ShowDialog
    {
        public ShowDialog()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region 非模态显示 MessageBox.showModelessDialog()
        /// <summary>
        /// 非模态显示
        /// </summary>
        /// <param name="this0">参数:this</param>
        /// <param name="url">显示页面的地址</param>
        /// <param name="width">显示小窗口的宽度</param>
        /// <param name="height">显示小窗口的高度</param>
        public static void showModelessDialog(Page this0, string url, int width, int height)
        {
            StringBuilder sb = new StringBuilder("");
            sb.Append("ReturnValue = window.showModelessDialog('" + url + "', window ,'dialogWidth=" + width.ToString() + "px;dialogHeight=" + height.ToString() + "px');");
            sb.Append("");
            ClientScriptManager cs = this0.ClientScript;
            if (!cs.IsStartupScriptRegistered(this0.GetType(), "showModelessDialog"))
            {
                cs.RegisterStartupScript(this0.GetType(), "showModelessDialog", sb.ToString(), true);
            }
        }
        #endregion

        #region 模态显示 MessageBox.showModalDialog()
        /// <summary>
        /// 模态显示
        /// </summary>
        /// <param name="this0">参数:this</param>
        /// <param name="url">显示页面的地址</param>
        /// <param name="width">显示小窗口的宽度</param>
        /// <param name="height">显示小窗口的高度</param>
        /// <param name="HideName">接受弹出页面的回传值,一般用Hiddden或文本框来接受</param>
        public static void showModalDialog(Page this0, string url, int width, int height, string HideName)
        {
            StringBuilder sb = new StringBuilder("");
            sb.Append("ReturnValue = window.showModalDialog('" + url + "', window ,'dialogWidth=" + width.ToString() + "px;dialogHeight=" + height.ToString() + "px');");
            sb.Append("window.document.all('" + HideName + "').value = ReturnValue");
            ClientScriptManager cs = this0.ClientScript;
            if (!cs.IsStartupScriptRegistered(this0.GetType(), "showModalDialog"))
            {
                cs.RegisterStartupScript(this0.GetType(), "showModalDialog", sb.ToString(), true);
            }
        }
        #endregion
    }
}